package health_system.health_system.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Data
@Component
@ConfigurationProperties(prefix = "app")
public class AppProperties {
    
    private final Jwt jwt = new Jwt();
    private final Upload upload = new Upload();
    private final Cors cors = new Cors();
    private final Cache cache = new Cache();
    private final HealthMonitor healthMonitor = new HealthMonitor();
    
    @Data
    public static class Jwt {
        private String secret;
        private long expiration;
        private long refreshExpiration = 604800000; // 7天 - 默认值
        private String header;
        private String prefix;
        private boolean secureCookie = false;
    }
    
    @Data
    public static class Upload {
        private String dir = "uploads";
        private String[] allowedExtensions;
        private long maxSize;
        private String momentsDir = "uploads/moments";
    }
    
    @Data
    public static class Cors {
        private String[] allowedOrigins;
        private String[] allowedMethods;
        private String[] allowedHeaders;
        private long maxAge;
    }
    
    @Data
    public static class Cache {
        private long defaultTtl;
    }
    
    @Data
    public static class HealthMonitor {
        private Range heartRate = new Range();
        private Range bloodOxygen = new Range();
        private Range temperature = new Range();
        private BloodPressure bloodPressure = new BloodPressure();
        
        @Data
        public static class Range {
            private double min;
            private double max;
        }
        
        @Data
        public static class BloodPressure {
            private Range systolic = new Range();
            private Range diastolic = new Range();
        }
    }
}